#ifndef __ILI9488_H__
#define __ILI9488_H__

#define   LCD_HOR           320
#define   LCD_VER           240

#define PIN_out(GPIOx,n) *(&GPIOx->DATAPIN0 + n) 
#define PINs_out(GPIOx)	 *((volatile uint32_t *) (uint32_t)&GPIOx->ODR) 
//#define GPIO_Ctrl  GPIOA
//#define GPIO_Ctrl2 GPIOC
//#define PIN_RD	PIN7
//#define PIN_CS  PIN4
//#define PIN_RS	PIN5
//#define PIN_WR	PIN6
//#define PIN_RST PIN2  //GPIOC2


#define PORT_WR	 GPIOD
#define PORT_RD	 GPIOD
#define PORT_CS  GPIOE
#define PORT_RS	 GPIOA
#define PORT_RST GPIOC

#define PIN_WR	PIN0
#define PIN_RD	PIN1
#define PIN_CS  PIN4
#define PIN_RS	PIN0
#define PIN_RST PIN2

#define CS_CLR  *((volatile uint32_t *) (uint32_t)&PORT_CS->DATAPIN0 + PIN_CS)=0 
#define RS_CLR  *((volatile uint32_t *) (uint32_t)&PORT_RS->DATAPIN0 + PIN_RS)=0 
#define RD_CLR  *((volatile uint32_t *) (uint32_t)&PORT_RD->DATAPIN0 + PIN_RD)=0 
#define WR_CLR  *((volatile uint32_t *) (uint32_t)&PORT_WR->DATAPIN0 + PIN_WR)=0 
#define RST_CLR *((volatile uint32_t *) (uint32_t)&PORT_RST->DATAPIN0 + PIN_RST)=0 

#define CS_SET  *((volatile uint32_t *) (uint32_t)&PORT_CS->DATAPIN0 + PIN_CS)=1
#define RS_SET  *((volatile uint32_t *) (uint32_t)&PORT_RS->DATAPIN0 + PIN_RS)=1
#define RD_SET  *((volatile uint32_t *) (uint32_t)&PORT_RD->DATAPIN0 + PIN_RD)=1
#define WR_SET  *((volatile uint32_t *) (uint32_t)&PORT_WR->DATAPIN0 + PIN_WR)=1
#define RST_SET *((volatile uint32_t *) (uint32_t)&PORT_RST->DATAPIN0 + PIN_RST)=1

#define LCD_I80_WriteCmd(data_L) {CS_CLR;RS_CLR;RD_SET;WR_SET;PINs_out(GPIOB)=data_L;WR_CLR;WR_SET;RS_SET;CS_SET;}
#define LCD_I80_WriteData(data_L) {CS_CLR;RS_SET;RD_SET;WR_SET;PINs_out(GPIOB)=data_L;WR_CLR;WR_SET;RS_SET;CS_SET;}
#define LCD_I80_WriteData_16bit(data_L) {WR_SET;PINs_out(GPIOB)=data_L;WR_CLR;}



//void LCD_I80_WriteCmd(uint8_t data_L);
//void LCD_I80_WriteData(uint8_t data_L);
//void LCD_I80_WriteData_16bit(uint16_t data);
void LCD_I80_WriteCmd_16bit(uint16_t data);
void LCD_I80_Write_16bit(uint16_t reg ,uint8_t data);
uint16_t LCD_I80_ReadReg(uint16_t reg);
void TFTInit(void);
void LCD_SingleColor(unsigned int RPG);
void LCD_TEST_JPG(int x1,int x2,int y1,int y2,const unsigned char *id);
void LCD_ShowString(uint16_t x,uint16_t y,uint16_t width,uint16_t height,uint8_t size,uint8_t *p,uint16_t color);
void Show_Str(uint16_t x,uint16_t y,uint16_t width,uint16_t height,uint8_t*str,uint8_t size,uint8_t mode,uint16_t color);
void Show_Font(uint16_t x,uint16_t y,uint8_t * font,uint8_t size,uint8_t mode,uint16_t color);
void LCD_DrawPoint(uint16_t x, uint16_t y, uint16_t c );
void LCD_XYSetColor(int x1,int x2,int y1,int y2,unsigned int RPG);
void adderset(int xs,int xe,int ys,int ye);

#endif